package com.farsunset.cim.client.android;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import android.content.Context;

/**
 * 
 *
 */
public class CIMDataConfig {

	public static String CIM_CONFIG_INFO = "CIM_CONFIG_INFO";

	public static String KEY_ACCOUNT = "KEY_ACCOUNT";

	public static String KEY_MANUAL_STOP = "KEY_MANUAL_STOP";

	public static String KEY_CIM_DESTORYED = "KEY_CIM_DESTORYED";

	public static String KEY_CIM_SERVIER_HOST = "KEY_CIM_SERVIER_HOST";

	public static String KEY_CIM_SERVIER_PORT = "KEY_CIM_SERVIER_PORT";
	
	//最小传输长度
	public final static int minReadBufferSize = 1024 * 20;
	
	/* 这一个对象用于缓存每一次上传的文件数据路径，每次上传后，将fileMap的key为文件的md5，File为此文件对象
	 *  在进行断点续传的时候，从fileMap中获取file对象 
	 */
	public static Map<String, File> fileMap = new HashMap<String, File>();

	public static void putString(Context context, String key, String value) {
		context.getSharedPreferences(CIM_CONFIG_INFO, Context.MODE_PRIVATE)
				.edit().putString(key, value).commit();
	}

	public static String getString(Context context, String key) {
		return context.getSharedPreferences(CIM_CONFIG_INFO,
				Context.MODE_PRIVATE).getString(key, null);
	}

	public static void putBoolean(Context context, String key, boolean value) {
		context.getSharedPreferences(CIM_CONFIG_INFO, Context.MODE_PRIVATE)
				.edit().putBoolean(key, value).commit();
	}

	public static boolean getBoolean(Context context, String key) {
		return context.getSharedPreferences(CIM_CONFIG_INFO,
				Context.MODE_PRIVATE).getBoolean(key, false);
	}

	public static void putInt(Context context, String key, int value) {
		context.getSharedPreferences(CIM_CONFIG_INFO, Context.MODE_PRIVATE)
				.edit().putInt(key, value).commit();
	}

	public static int getInt(Context context, String key) {
		return context.getSharedPreferences(CIM_CONFIG_INFO,
				Context.MODE_PRIVATE).getInt(key, 0);
	}
}
